require('./details.less')

//引入axios
const axios = require('axios')

//引入dom.js
const { $, g, ga } = require('../../utlis/dom')

//引入字体图标
require('../../libs/fonts/iconfont.css')

$(function () {
    //回到上一步
    his.addEventListener('click', function () {
        history.go(-1)
    })

    //获取hash
    let id1 = location.hash.substring(1)
    // console.log(id1)
    axios.get('http://47.96.154.185:3701/api/train/courseDetail', {
        params: {
            id: id1
        }
    }).then(function (res) {

        if (res.data.errno === 0) {
             console.log(res.data.data)
            localStorage.setItem('fragments', JSON.stringify(res.data.data.fragments))
            let courseValue = res.data.data
            g('#name').textContent = courseValue.name
            g('#desc').textContent = courseValue.desc
            g('#imgurl').src = 'http://47.96.154.185:3701' + courseValue.imgurl
            g('#calorie').textContent = courseValue.calorie
            g('#time').textContent = courseValue.time
            g('#frequency').textContent = courseValue.frequency
        }
    })
})